#include <bits/stdc++.h>

using namespace std;

#define fi(i, init, n) for (int i = init; i < n; i++)   // i为循环变量，a为初始值，n为界限值，递增
#define rfi(i, init, n) for (int i = init; i > n; i--)  // i为循环变量， a为初始值，n为界限值，递减。
#define vi vector<int>
#define mii unordered_map<int, int>
#define between(a, l, h) (a >= l && a <= h)
const int INF = 0x7fffffff;  // 无穷大
typedef long long ll;

class Solution {
public:
    string compressedString(string word) {
        string ans;
        int len = 1;
        fi(i, 0, word.size()) {
            while (word[i] == word[i + 1] && len < 9) {
                i++;
                len++;
            }
            ans.append(to_string(len));
            ans.push_back(word[i]);
            len = 1;
        }
        return ans;
    }
};

